
<!DOCTYPE html>
<html>
	<head>
		<title>Testing CanvasJS with Xamarin C# bridge</title>
	</head>
<body>
    Testing CanvasJS with Xamarin C# bridge
</body>
   
    <div id="chartContainer" style="height: 300px; width: 100%;"></div>
    <script type="text/javascript" src="canvasjs.min.js"></script>
    <script language="javascript">
    	var chart;
    	var points;
        
        function onViewModelData(model) {
            var v;
            if (model.title === undefined) {
                v = JSON.parse(model);
            } else {
                v = model;
            }

            //Native("dataCallback", v.dataPoints);
            if (!chart)
            {
            	points = v.dataPoints;
				chart = new CanvasJS.Chart("chartContainer", {
	                theme: "theme2",
	                title: {
	                    text: v.title
	                },
	                data: [{ type: "column", dataPoints: v.dataPoints }]
	            });
           	}
           	else
           	{
           		chart.options.data = null;
           		chart.options.data  = [{ type: "column", dataPoints: v.dataPoints }];
           		//chart.options.data[0].dataPoints = null;
           		//chart.options.data[0].dataPoints = v.dataPoints;
           		//update(v.dataPoints);
	            //chart.data.dataPoints = v.dataPoints;
           	}
            

            chart.render();
            onUpdateFinished();

            Native("dataCallback", "test");
        }
        
        function sendData(o) {
            Native("dataCallback", o);
        }
        
        function sendData(o,b) {
            Native("dataCallback", [o, b]);
        }

        function onUpdateFinished(){
        	Native("chartUpdated", chart);
        }
    </script>
    
</html>
</!DOCTYPE>
